<template>
  <div class="dialog-container" :style="{ width: width + 'px', height: height + 'px' }" v-show="visible">
    <div class="title-area">
      {{ title }}
      <div class="close-btn" @click="emit('close')">×</div>
    </div>
    <div class="content-area" :style="{ height: height - 25 + 'px' }">
      <slot></slot>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const props = defineProps({
  width: {
    type: Number,
    default: 370,
  },
  height: {
    type: Number,
    default: 290,
  },
  visible: {
    type: Boolean,
    required: true,
  },
  title: {
    type: String,
    default: '标题',
  },
});
const emit = defineEmits(['close']);

</script>

<style scoped lang="scss">
.dialog-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  padding: 8px;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 0 6px #eee;
  z-index: 100;
  .content-area {
    width: 100%;
    overflow: auto;
  }
  .content-area::-webkit-scrollbar {
    display: none;
  }
}
.title-area {
  width: 100%;
  line-height: 25px;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  color: rgb(0, 56, 0);
  position: relative;
  .close-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 23px;
    line-height: 23px;
    text-align: center;
    font-weight: bold;
    font-size: 15px;
    color: black;
    background-color: rgb(240, 240, 240);
    border-radius: 50%;
    border: 1px solid #ddd;
    cursor: pointer;
  }
}
</style>
